load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")

proto_library(
    name = "rspb_proto",
    srcs = ["summary.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/util/hlc:hlc_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
    ],
)

go_proto_library(
    name = "rspb_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/readsummary/rspb",
    proto = ":rspb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/util/hlc",
        "//pkg/util/uuid",  # keep
        "@com_github_gogo_protobuf//gogoproto",
    ],
)

go_library(
    name = "rspb",
    srcs = [
        "merge_spans.go",
        "summary.go",
    ],
    embed = [":rspb_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvserver/readsummary/rspb",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/util/buildutil",
        "//pkg/util/encoding",
        "//pkg/util/hlc",
        "//pkg/util/uuid",
    ],
)

go_test(
    name = "rspb_test",
    srcs = [
        "merge_spans_test.go",
        "summary_test.go",
    ],
    embed = [":rspb"],
    deps = [
        "//pkg/util/hlc",
        "//pkg/util/randutil",
        "//pkg/util/uuid",
        "@com_github_stretchr_testify//require",
    ],
)
